﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Data.Entity;
using ASPNETMVC4Tutorial.Migrations;

namespace ASPNETMVC4Tutorial.Models
{
    public class EFContext: DbContext
    {
        public DbSet<Blog> Blogs { get; set; }
        public DbSet<Post> Posts { get; set; }

        public DbSet<Order> Orders { get; set; }
        public DbSet<OrderDetails> OrderDetails { get; set; }
        public DbSet<Product> Products { get; set; }

        public DbSet<Movie> Movies { get; set; }

        public DbSet<Album> Albums { get; set; }


        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            // automatic migrations of DB to latest code based model
            //临时注解掉这句话，当add controller by wizard时候遇到错误
            //There was an error generating 'ASPNETMVC4Tutorial.Models.EFContext. Try rebuilding your project
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<EFContext, Configuration>());

        }

        public DbSet<Student> Students { get; set; }

        public DbSet<Score> Scores { get; set; }
    }
}